package LFhalf {
	public class PlayerInput
	{
		/*
		 * 1empty
		 * 2release
		 * 3store
		 * 4press start
		 * 5pressing
		 * 6double click
		 * 7store double click
		 * */
		public var direct:uint=5;
		public var directState:uint=0;
		public var AState:uint=0;
		public var JState:uint=0;
		public var DState:uint=0;
		public var SState:uint=0;
		public var special:uint = 0;
		public function toUINT():uint {
			return direct + directState * 10 + AState * 100 + JState * 1000 + DState * 10000 + SState * 100000 + special * 1000000;
		}
		public function fromUINT(i:uint):PlayerInput {
			return new PlayerInput(i % 10,Math.floor(i / 10) % 10,Math.floor(i / 100) % 10,Math.floor(i / 1000) % 10,Math.floor(i / 10000) % 10,Math.floor(i / 100000) % 10,Math.floor(i / 1000000) % 10);
		}
		public function PlayerInput(_direct:uint, _directState:uint, _AState:uint,
			_JState:uint,_DState:uint,_SState:uint,_special:uint) {
			direct = _direct;
			directState = _directState;
			AState = _AState;
			JState = _JState;
			DState = _DState;
			SState = _SState;
			special = _special;
		}
		public function get directX():int {
			return (direct - 1) % 3 - 1;
		}
		public function get directY():int {
			return Math.floor((direct - 1) / 3) - 1;
		}
		public function down(_key:String):Boolean {
			return this[_key + 'State'] > 3;
		}
		public function press(_key:String):Boolean {
			return this[_key + 'State']==4 || this[_key + 'State']==6 || this[_key + 'State']==3;
		}
	}
}